#ifndef _HELPER_MACRO_H
#define _HELPER_MACRO_H

#ifndef NDEBUG
#define _ASSERT_EXP(exp) assert( exp )
#define _ALERT_FAILED assert( false )
#define _ASSERT_OK(exp) assert( (exp) == Acad::eOk )
#define _ASSERT_NOT_NULL(exp) assert( (exp) != 0 )
#else
#define _ASSERT_EXP(exp)
#define _ALERT_FAILED
#define _ASSERT_OK(exp)
#define _ASSERT_NOT_NULL(exp)
#endif

//helper macros used simplifing coding
#define _ASSERT_RETURN( condition, retVal ) \
	if ( !(condition) ) { return retVal; }

#define _ASSERT_RETURN_VOID( condition ) \
	if ( !(condition) ) { return; }

#define _ASSERT_PROCESS_RETURN( condition, preProcess, retVal ) \
	if ( !(condition) ) { preProcess; return retVal; }

#define _ASSERT_PROCESS_RETURN_VOID( condition, preProcess ) \
	if ( !(condition) ) { preProcess; return; }

#define _ASSERT_ALERT_RETURN( condition, retVal ) \
	if ( !(condition) ) { _ALERT_FAILED; return retVal; }

#define _ASSERT_ALERT_RETURN_VOID( condition ) \
	if ( !(condition) ) { _ALERT_FAILED; return; }

#define _ASSERT_PROCESS_ALERT_RETURN( condition, preProcess, retVal ) \
	if ( !(condition) ) { preProcess; _ALERT_FAILED; return retVal; }

#define _ASSERT_PROCESS_ALERT_RETURN_VOID( condition, preProcess ) \
	if ( !(condition) ) { preProcess; _ALERT_FAILED; return; }

#define _ASSERT_OK_ALERT_RETURN( es ) \
	if ( (es) != Acad::eOk ) { _ALERT_FAILED; return es; }

#define _ASSERT_OK_ALERT_RETURN_VOID( es ) \
	if ( (es) != Acad::eOk ) { _ALERT_FAILED; return; }

#define _ASSERT_OK_PROCESS_ALERT_RETURN( es, preProcess ) \
	if ( (es) != Acad::eOk ) { preProcess; _ALERT_FAILED; return es; }

#define _ASSERT_OK_PROCESS_ALERT_RETURN_VOID( condition, preProcess ) \
	if ( (es) != Acad::eOk ) { preProcess; _ALERT_FAILED; return; }

#define _ALERT_RETURN( retVal ) { _ALERT_FAILED; return retVal; }
#define _ALERT_RETURN_VOID { _ALERT_FAILED; return; }

//helper macros used for math arithmetic
#define _0_UPPER_VALVE 1.0e-10
#define _0_LOWER_VALVE -1.0e-10
#define _LOWER_THAN_0( exp ) ( (exp) < _0_LOWER_VALVE )
#define _UPPER_THAN_0( exp ) ( (exp) > _0_UPPER_VALVE )
#define _EQUAL_0( exp ) ( (exp) >= _0_LOWER_VALVE && (exp) <= _0_UPPER_VALVE )

#define _EQUAL( exp1, exp2 ) ( _EQUAL_0( (exp1) - (exp2) ) )
#define _LOWER_THAN( exp1, exp2 ) ( _LOWER_THAN_0( (exp1) - (exp2) ) )
#define _UPPER_THAN( exp1, exp2 ) ( _UPPER_THAN_0( (exp1) - (exp2) ) )

const double PI = 3.1415926535897932384626433832795;

#define _EQUAL_0_ACAD( exp ) ( fabs(exp) <= AcGeContext::gTol.equalPoint() )
#define _LOWER_THAN_0_ACAD( exp ) ( (exp) < -AcGeContext::gTol.equalPoint() )
#define _UPPER_THAN_0_ACAD( exp ) ( (exp) > AcGeContext::gTol.equalPoint() )

#define _EQUAL_ACAD( exp1, exp2 ) ( _EQUAL_0_ACAD( (exp1) - (exp2) ) )
#define _LOWER_THAN_ACAD( exp1, exp2 ) ( _LOWER_THAN_0_ACAD( (exp1) - (exp2) ) )
#define _UPPER_THAN_ACAD( exp1, exp2 ) ( _UPPER_THAN_0_ACAD( (exp1) - (exp2) ) )

#endif